package com.estate.business.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.estate.business.TenderPublishService;
import com.estate.dao.TenderPublishDao;
import com.estate.utils.DeleProjectUtil;
import com.estate.vo.Vo;
import com.estate.vo.impl.DeleProjectVo;
import com.estate.vo.impl.TenderCopyVo;
import com.estate.vo.impl.TenderPublishVo;
import com.estate.vo.impl.UserInfoVo;

public class TenderPublishServiceImpl implements TenderPublishService {

	private TenderPublishDao tenderPublishDao;

	public TenderPublishDao getTenderPublishDao() {
		return tenderPublishDao;
	}

	public void setTenderPublishDao(TenderPublishDao tenderPublishDao) {
		this.tenderPublishDao = tenderPublishDao;
	}
	
	public boolean addTenderPublish(TenderPublishVo tenderPublish) {
		boolean result =false; 
		result = this.getTenderPublishDao().addVo(tenderPublish);
		return result;
	}

	public List<Vo> getList() {
		List<Vo> allList = this.getTenderPublishDao().findAll();
		return allList;
	}

	public TenderPublishVo getTenderPublish(int id) {
		TenderPublishVo project = (TenderPublishVo) this.getTenderPublishDao().findByPK(id);
		return project;
	}

	public boolean updateTenderPublish(TenderPublishVo tenderPublish){
		boolean result =false;
		TenderPublishVo old = this.getTenderPublish(tenderPublish.getId());
		tenderPublish.setPostDate(old.getPostDate());
		tenderPublish.setPostUser(old.getPostUser());
		tenderPublish.setTender(old.getTender());
		result = this.getTenderPublishDao().updateVo(tenderPublish);
		return true;
	}
	
	public boolean deleteMultiTenderPublish(String delStr){
		if(delStr!= null && !"".equals(delStr) && !",".equals(delStr)){
			String[] delArray = delStr.split(",");
			TenderPublishVo tenderPublish = null;
			for(int i = 0;i<delArray.length;i++){
				tenderPublish = new TenderPublishVo();
				tenderPublish.setId(Integer.parseInt(delArray[i]));
				this.deleteTenderPublish(tenderPublish);
			}
		}
		return true;
	}
	
	public boolean deleteTenderPublish(TenderPublishVo tenderPublish){
		boolean result = false;
		result = this.getTenderPublishDao().deleteVo(tenderPublish);
		return result;
	}
}
